package com.lsh.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lsh.mapper.StuMapper;
import com.lsh.pojo.PageBean;
import com.lsh.pojo.student;
import com.lsh.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StuServiceImpl implements StuService {
    @Autowired
    private StuMapper stuMapper;

    @Override
    public List<student> list() {
        return stuMapper.list();
    }

    @Override
    public PageBean page(Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);

        List<student> studentList = stuMapper.list();
        Page<student> p = (Page<student>) studentList;
        PageBean pageBean = new PageBean(p.getTotal(), p.getResult());
        return pageBean;
    }

    @Override
    public student getById(String sno) {
        return stuMapper.getById(sno);
    }

    @Override
    public void addStu(student stu) {
        stuMapper.addStu(stu);
    }

    @Override
    public void update(student stu) {
        stuMapper.update(stu);
    }

    @Override
    public void delete(String sno) {
        stuMapper.delete(sno);
    }

    @Override
    public student login(student stu) {
        return stuMapper.login(stu);
    }

    @Override
    public void rgst(student stu) {
        stuMapper.addStu(stu);
    }
}
